package com.jxs.android.soap;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

import android.util.Log;

public class BuWebService {

	private String wsdl_url = "";
	private SoapObject request;

	private boolean doNet;

	public boolean isDoNet() {
		return doNet;
	}

	public void setDoNet(boolean doNet) {
		this.doNet = doNet;
	}

	/**
	 * @param wsdl_url
	 * @param request
	 */
	public BuWebService(String wsdl_url, SoapObject request) {
		this.wsdl_url = wsdl_url;
		this.request = request;
	}

	public void requestWSDL(IWebService iWebService) {
		SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
		envelope.implicitTypes = true;
		envelope.dotNet = isDoNet();
		envelope.bodyOut = request;
		HttpTransportSE httpTransportSE = new HttpTransportSE(wsdl_url, 600000);
		try {
			httpTransportSE.call(null, envelope);// 调用
			if (null != iWebService)
				iWebService.logic(envelope);
		} catch (Exception e) {
			if (null != iWebService)
				iWebService.error("无数据返回，请稍后重试...", e);
			Log.e("Exception", "Exception", e);
		}
	}
}
